/*
 * OPIAM Suite
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */

package opiam.admin.faare.struts.service.beans;

import opiam.admin.faare.struts.service.MenuFeaturePluginInterface;


/**
 * This class is a menu feature element, corresponding to the "feature" element
 * of the menus_conf.xml file.
 *
 */
public class JBFeature
{
    /** Menu element name. */
    private String name;

    /** Icon to be associated with the active menu element. */
    private String onicon;

    /** Icon to be associated with the inactive menu element. */
    private String officon;

    /** Menu element URI. */
    private String url;

    /** Menu element label. */
    private String label;

    /** Name of the class implementing MenuFeaturePluginInterface if any. */
    private String classname;

    /** Class implementing MenuFeaturePluginInterface if any. */
    private MenuFeaturePluginInterface plugin = null;

    /** Menu element HTTP parameter name. */
    private String paramId;

    /** Object carrying the parameter. */
    private String paramName;

    /** Property carrying the parameter. */
    private String paramProperty;

    /** Object carrying plugin parameter. */
    private String currentObjname;

    /** Property carrying plugin parameter. */
    private String currentObjprop;
    
    //DW/2666/BeginPatch
    /** Property indicating where to open the target URL. */
    private String target;
    //DW/2666/EndPatch

    /**
     * Returns the menu element label.
     * @return label
     */
    public String getLabel()
    {
        return label;
    }

    /**
     * Returns the menu element name.
     * @return name
     */
    public String getName()
    {
        return name;
    }

    /**
     * Returns the menu element URI.
     * @return URI
     */
    public String getUrl()
    {
        return url;
    }

    /**
     * Sets the menu element label.
     * @param alabel The label to set
     */
    public void setLabel(String alabel)
    {
        this.label = alabel;
    }

    /**
     * Sets the menu element name.
     * @param aname The name to set
     */
    public void setName(String aname)
    {
        this.name = aname;
    }

    /**
     * Sets the menu URI.
     * @param aurl The URI to set
     */
    public void setUrl(String aurl)
    {
        this.url = aurl;
    }

    /**
     * Displays the menu element.
     *
     * @return String formatted menu element definition.
     */
    @Override
	public String toString()
    {
        StringBuffer buf = new StringBuffer();
        java.util.Iterator it = null;

        buf.append("name = ");
        buf.append(name);
        buf.append(System.getProperty("line.separator"));
        buf.append("onicon = ");
        buf.append(onicon);
        buf.append(System.getProperty("line.separator"));
        buf.append("officon = ");
        buf.append(officon);
        buf.append(System.getProperty("line.separator"));
        buf.append("url = ");
        buf.append(url);
        buf.append(System.getProperty("line.separator"));
        buf.append("label = ");
        buf.append(label);
        buf.append(System.getProperty("line.separator"));
        buf.append("classname = ");
        buf.append(classname);
        buf.append(System.getProperty("line.separator"));
        //DW/2666/BeginPatch
        buf.append("target = ");
        buf.append(target);
        buf.append(System.getProperty("line.separator"));
        //DW/2666/EndPatch

        return buf.toString();
    }

    // end of toString method

    /**
     * Returns the icon to be associated with the inactive menu element.
     * @return icon URI
     */
    public String getOfficon()
    {
        return officon;
    }

    /**
     * Returns the icon to be associated with the active menu element.
     * @return icon URI
     */
    public String getOnicon()
    {
        return onicon;
    }

    /**
     * Sets the icon to be associated with the inactive menu element..
     * @param aofficon The icon URI to set
     */
    public void setOfficon(String aofficon)
    {
        this.officon = aofficon;
    }

    /**
     * Sets the icon to be associated with the active menu element.
     * @param aonicon The icon URI to set
     */
    public void setOnicon(String aonicon)
    {
        this.onicon = aonicon;
    }

    /**
     * Returns the name of the class implementing MenuFeaturePluginInterface.
     * @return class name or null
     */
    public String getClassname()
    {
        return classname;
    }

    /**
     * Sets the the name of the class implementing MenuFeaturePluginInterface.
     * @param aclassname The class name to set
     */
    public void setClassname(String aclassname)
    {
        this.classname = aclassname;
        try
        {
            Class cl = Class.forName(classname);
            plugin = (MenuFeaturePluginInterface) cl.newInstance();
        }
        catch (Exception ex)
        {
            throw new RuntimeException("pb dans setClassname");

            //ex.printStackTrace();
        }
    }

    /**
     * Returns the class implementing MenuFeaturePluginInterface..
     * @return class implementing MenuFeaturePluginInterface or null
     */
    public MenuFeaturePluginInterface getPlugin()
    {
        return plugin;
    }

    /**
     * Returns the element HTTP parameter name.
     * @return parameter name
     */
    public String getParamId()
    {
        return paramId;
    }

    /**
     * Returns the object carrying the HTTP parameter.
     * @return object name
     */
    public String getParamName()
    {
        return paramName;
    }

    /**
     * Returns the property carrying the HTTP parameter.
     * @return property name
     */
    public String getParamProperty()
    {
        return paramProperty;
    }

    /**
     * Sets the the element HTTP parameter name.
     * @param aparamId The parameter name to set
     */
    public void setParamId(String aparamId)
    {
        this.paramId = aparamId;
    }

    /**
     * Sets the object carrying the HTTP parameter.
     * @param aparamName The name of the object to set
     */
    public void setParamName(String aparamName)
    {
        this.paramName = aparamName;
    }

    /**
     * Sets the the property carrying the HTTP parameter.
     * @param aparamProperty The name of the property to set
     */
    public void setParamProperty(String aparamProperty)
    {
        this.paramProperty = aparamProperty;
    }

    /**
     * Returns the object carrying plugin parameter.
     * @return name of the object
     */
    public String getCurrentObjname()
    {
        return currentObjname;
    }

    /**
     * Returns the property carrying plugin parameter.
     * @return name of the property or null
     */
    public String getCurrentObjprop()
    {
        return currentObjprop;
    }

    /**
     * Sets the object carrying plugin parameter.
     * @param acurrentObjname The name of the object to set
     */
    public void setCurrentObjname(String acurrentObjname)
    {
        this.currentObjname = acurrentObjname;
    }

    /**
     * Sets the property carrying plugin parameter..
     * @param acurrentObjprop The name of the property to set
     */
    public void setCurrentObjprop(String acurrentObjprop)
    {
        this.currentObjprop = acurrentObjprop;
    }
    //DW/2666/BeginPatch
	/**
	 * Gets the location indicator of the target URL.  
	 *
	 * @return The target or null.
	 */
	public String getTarget() {
		return target;
	}
	/**
	 * Sets the location indicator of the target URL.
	 *
	 * @param target  The target to set.
	 */
	public void setTarget(String target) {
		this.target = target;
	}
    //DW/2666/EndPatch
}
